import Bean.CarDetail;
import Utils.DBUtils;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;

public class Test {
    public static void main(String[] args) {
        //创建一个集合用来存放汽车对象
        ArrayList<CarDetail> list = new ArrayList<>();
        String sql ="select * from CarDetail";
        ResultSet rs = DBUtils.query(sql);
        try {
            while (rs.next()){
                int cid = rs.getInt("CID");
                String cname = rs.getString("Cname");
                String content = rs.getString("Content");
                Date lTime = rs.getDate("LTime");
                int price = rs.getInt("price");
                int brandID = rs.getInt("BrandID");
                //将获取的数据封装成一个对象并添加到集合
                CarDetail car = new CarDetail(cid, cname, content, lTime, price, brandID);
                list.add(car);
                System.out.println(car);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
